﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page contentType="text/html; charset=utf-8"%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>个人基础信息修改</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<script src="${pageContext.request.contextPath }/scripts/boot.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath }/scripts/LodopFuncs.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath }/scripts/PrintSample10.js" type="text/javascript"></script>
<style type="text/css">
    html, body
    {
        font-size:12px;
        padding:0;
        margin:0;
        border:0;
        height:100%;
        overflow:hidden;
    }
    .asLabel .mini-textbox-border,
    .asLabel .mini-textbox-input,
    .asLabel .mini-buttonedit-border,
    .asLabel .mini-buttonedit-input,
    .asLabel .mini-textboxlist-border
    {
        border:0;background:none;cursor:default;
    }
    .asLabel .mini-buttonedit-button,
    .asLabel .mini-textboxlist-close
    {
        display:none;
    }
    .asLabel .mini-textboxlist-item
    {
        padding-right:8px;
    } 
</style>
</head>
<body>
<fieldset style="border:solid 1px #aaa;padding:3px;">
  <legend >个人基础信息</legend> 
  <form id="form1"  method="post">
  <div style="padding-left:11px;padding-bottom:5px;">
      <table style="table-layout:fixed;">
        <tr>
          <td style="width:20%;white-space:nowrap;text-align:right;"><span style="color:red;">*</span>社会保障卡号：</td>
          <td style="width:30%;"><input name="aac001" id="aac001" class="mini-textbox sasLabel asLabel" borderStyle="border:0" 
          								readonly="true" allowInput="false" maxlength="12" style="width:100%;"/></td>
          <td style="width:20%;white-space:nowrap;text-align:right;"><span style="color:red;">*</span>省个人识别号：</td>
          <td style="width:30%;"><input name="baz805" id="baz805" class="mini-textbox sasLabel asLabel" borderStyle="border:0" 
          								readonly="true" allowInput="false"  maxlength="12" style="width:100%;"/></td>
        </tr> 
        <tr>
          <td style="width:20%;white-space:nowrap;text-align:right;"><span style="color:red;">*</span>姓名：</td>
          <td style="width:30%;"><input name="aac003" class="mini-textbox asLabel" onvalidation="isNumber" required="true" maxlength="25" 
          								style="width:100%;" emptyText="请输入姓名"/></td>
          <td style="width:20%;white-space:nowrap;text-align:right;"><span style="color:red;">*</span>证件类型：</td>
          <td style="width:30%;"><input name="aac058" class="mini-combobox asLabel" valueField="aaa102" textField="aaa103"
                                        id="aac058" onvaluechanged="accept" style="width:100%;"
                                        url="${pageContext.request.contextPath }/AC01.do?method=getselectaac058&lx=AAC058"
                                        required="true" emptyText="请选择证件类型"/></td>        
        </tr>
        <tr>
          <td style="width:20%;white-space:nowrap;text-align:right;"><span style="color:red;">*</span>证件号码：</td>
          <td style="width:30%;"><input name="aac002" class="mini-textbox asLabel" required="true"
                                        onvalidation="onisLength" onvaluechanged="onNumber" onenter="onKeyEnter" maxlength="18" style="width:100%;" emptyText="请输入证件号"/></td>
		  <td style="width:12%;text-align:right;white-space:nowrap;">证件有效期限：</td>
		  <td style="width:22%;"><input name="aacc01" class="mini-datepicker asLabel" allowInput="false" style="width:100%;"  emptyText="请输入证件有效期限"/></td>
        </tr>
        <tr>
          <td style="width:20%;white-space:nowrap;text-align:right;"><span style="color:red;">*</span>出生日期：</td>
          <td style="width:30%;"><input id="aac006" name="aac006" class="mini-datepicker asLabel" allowInput="false" required="true"  onvalidation="onBirthday"
                                 format="yyyy-MM-dd" id="aac006" emptyText="请选择日期" style="width:100%;"/></td>
          <td style="width:20%;white-space:nowrap;text-align:right;"><span style="color:red;">*</span>性别：</td>
          <td style="width:30%;"><input name="aac004" class="mini-combobox asLabel" valueField="aaa102" textField="aaa103" id="aac004" 
                                        url="${pageContext.request.contextPath }/AC01.do?method=getselect&lx=AAC004"
                                        required="true" emptyText="请选择性别" style="width:100%;"/></td>
        </tr>
        <tr>
          <td style="width:20%;white-space:nowrap;text-align:right;"><span style="color:red;">*</span>民族：</td>
          <td style="width:30%;"><input name="aac005" onvaluechanged="change" required="true" class="mini-combobox asLabel" valueField="aaa102" textField="aaa103" id="aac005" 
                                        url="${pageContext.request.contextPath }/AC01.do?method=getselect&lx=AAC005"
                                        emptyText="请选择民族" style="width:100%;"/></td>
          <td style="width:20%;white-space:nowrap;text-align:right;"><span style="color:red;">*</span>国籍或地区：</td>
          <td style="width:30%;"><input name="aac161" class="mini-combobox asLabel" valueField="aaa102" textField="aaa103" id="aac161" 
                                        url="${pageContext.request.contextPath }/AC01.do?method=getselect&lx=AAC161"
                                        required="true" emptyText="请选择国籍或地区" style="width:100%;"/></td>    
        </tr>
        <tr>
           <td style="width:12%;text-align:right;white-space:nowrap;"><span style="color:red;">*</span>联系电话：</td>
		   <td style="width:22%;"><input name="aae005" class="mini-textbox asLabel" required="true"  style="width:100%;" vtype="int;minLength:7" 
		   						 maxlength="11" emptyText="请输入联系电话"/></td>
        </tr>
        <tr>
          <td style="width:12%;white-space:nowrap;text-align:right;"><span style="color:red;">*</span>变更原因：</td>
          <td colspan="5" id="aae160"><input name="aae160" class="mini-textarea asLabel" required="true"  maxlength="200" 
          								emptyText="请简要输入变更原因" style="width:96%;"/></td>
        </tr>
        <tr>
          <td style="width:12%;white-space:nowrap;text-align:right;" id="abstract_demand_lable">备注：</td>
          <td colspan="5" id="aae013"><input name="aae013" class="mini-textarea"  maxlength="200" emptyText="备注" style="width:96%;"/></td>
        </tr>
      </table>
    </div>
    <div style="text-align:center;padding:10px;">
      <a class="mini-button" id="onoks" name="onoks" onclick="onOk" iconCls="icon-ok" style="width:60px;margin-right:20px;">确定</a>
      <a class="mini-button" onclick="onCancel" iconCls="icon-close" style="width:60px;margin-right:20px;"">取消</a>
      <a class="mini-button" id="print" name="print" onclick="view" enabled="false" iconCls="icon-print" style="width:60px;margin-right:20px;">打印</a>
    </div>
  </form>
</fieldset>
<script type="text/javascript">
    mini.parse();
    var form = new mini.Form("form1");
    var tag = true;
    var fag = true;
    //数据保存
    function SaveData() {
      var o = form.getData();
      form.validate();
      if (form.isValid() == false) return;
      	if(form.isValid()==true){
      	   mini.mask({el: document.body,cls: 'mini-mask-loading',html: '修改中...'});
      	 }
         var json = mini.encode([o]);
         $.ajax({
                url: "/zyk/AC01.do?method=saveAC01&random="+Math.random()*100,
                type: 'post',
                data: { data: json},
                cache: false,
                success: function (text) {
               		if(text == "修改成功"){
               		   mini.unmask();
               		   mini.alert(text);
               		   mini.get("print").setEnabled(true);
               		   mini.get("onoks").setEnabled(false); 
               		   labelModel();
               		}else{
               		   mini.unmask();
               		   mini.alert(text); 	    			
               		}
                },
                error: function (jqXHR, textStatus, errorThrown) {
                    mini.alert(jqXHR.responseText);
                    CloseWindow();
                }
            });
     }
     
    //标准方法接口定义
    function SetData(data) {
      if (data.action == "edit") {
         //跨页面传递的数据对象，克隆后才可以安全使用
         data = mini.clone(data);
         $.ajax({
                url: "${pageContext.request.contextPath }/AC01.do?method=getAC01data&id=" + data.id,
                cache: false,
                success: function (text) {
                    var o = mini.decode(text);
                    form.setData(o);
                    form.setChanged(false);
                    }
                });
        }
    }
     function onisLength(e){
    	 var aac058=mini.getbyName("aac058").getValue();
        if(aac058== '01'){
        	var pattern=/^(\d{15})$/;
        	if(pattern.test(e.value)){
        	mini.alert("身份证长度错");
        	e.errorText="身份证长度错";
            e.isValid=false;
            mini.getbyName("aac006").setValue("");
            mini.getbyName("aac004").setValue("");
        	}
        }
    }
	 function labelModel() {
            var fields = form.getFields();                
            for (var i = 0, l = fields.length; i < l; i++) {
                var c = fields[i];
                if (c.setReadOnly) c.setReadOnly(true);     //只读
                if (c.setIsValid) c.setIsValid(true);      //去除错误提示
                if (c.addCls) c.addCls("asLabel");          //增加asLabel外观
            }
        }
      window.onload=function inputModel() {
            var fields = form.getFields();
            for (var i = 0, l = fields.length; i < l; i++) {
                var c = fields[i];
                if (c.setReadOnly) c.setReadOnly(false);
                if (c.removeCls) c.removeCls("asLabel");
            }
            mini.repaint(document.body);
        }
    // 根据所选的证件的类型自动输入国籍并清空其他关联项
    function accept(){
        var zjlx=mini.get("#aac058").getValue();
        if(zjlx == '01'||zjlx == '02'||zjlx == '03') {
            mini.get("#aac161").setValue("CHN");
            mini.getbyName("aac002").setValue("");
            mini.getbyName("aac006").setValue("");
        }else if(zjlx == '04') {
            mini.get("#aac161").setValue("HKG");
            mini.getbyName("aac002").setValue("");
            mini.getbyName("aac006").setValue("");
        }else if(zjlx == '05') {
            mini.get("#aac161").setValue("MAC");
            mini.getbyName("aac002").setValue("");
            mini.getbyName("aac006").setValue("");
        }else if(zjlx == '06') {
            mini.get("#aac161").setValue("TWN");
            mini.getbyName("aac002").setValue("");
            mini.getbyName("aac006").setValue("");
        }else {
            mini.get("#aac161").setValue("");
            mini.getbyName("aac002").setValue("");
            mini.getbyName("aac006").setValue("");
        }
    }
        function onisLength(e){
    	 var aac058=mini.getbyName("aac058").getValue();
        if(aac058== '01'){
        	var pattern=/^(\d{15})$/;
        	if(pattern.test(e.value)){
        	mini.alert("身份证长度错");
        	e.errorText="身份证长度错";
            e.isValid=false;
            mini.getbyName("aac006").setValue("");
            mini.getbyName("aac004").setValue("");
        	}
        }
    }
    //证件重复性和合法性验证
    function onNumber(e){
        var aac002 = mini.getbyName("aac002").getValue().trim();
        var aac058=mini.getbyName("aac058").getValue();
        //身份证合法性验证
        if(aac058 == '01'){ 
         $.ajax({   
          url: "/zyk/AC01.do?method=checksfz&id="+ aac002+"&random="+Math.random()*100,                
          success: function(res){  
            if("0"!=res){
                mini.alert(res);
            }else{
                mini.get("#aac006").setValue(e.value.substring(6,14));
                mini.get("#aac004").setValue(e.value.substring(16,17)%2?"1":"2");
            }                             
           }
         });          
       }
    }
    //身份证合法型验证
    function isNumber(v){
        var tel = /^\d{6}(18|19|20)?\d{2}(0[1-9]|1[12])(0[1-9]|[12]\d|3[01])\d{3}(\d|X)$/i;
        var flag = true;
        if(!tel.test(v)){
            flag = false;
        }else{
            var arrInt = new Array(7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2);
            var arrCh = new Array('1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2');
            var nTemp = 0, i;
            var temp = v.substring(0,17);
            for (i = 0; i < temp.length; i++) {
                 nTemp += temp.substr(i, 1) * arrInt[i];
                }
                temp += arrCh[nTemp % 11];
            if(temp != v) {
               flag = false;
            }
        }
          return flag;
    }
    // 出生日期验证
    function onBirthday(e){
      var newDate = new Date();
      var aac006 = mini.get("#aac006").getValue();
      var nowDate = newDate.getFullYear()+"/"+((newDate.getMonth()+1)<10?"0":"")+(newDate.getMonth()+1)+"/"+(newDate.getDate()<10?"0":"")+newDate.getDate();
      var now_Date = new Date(Date.parse(nowDate));
      var AAC006 = new Date(Date.parse(aac006));
      if (AAC006 > now_Date) {
         e.errorText = "出生日期超过当前日期";
         e.isValid = false;
       }
    }
    // 数据保存
    function onOk() {
        var aac002 = mini.getbyName("aac002").getValue().trim();
        var aac058=mini.getbyName("aac058").getValue();
        var aac001 = mini.getbyName("aac001").getValue();
         $.ajax({
            url: "/zyk/AC01.do?method=getaac147",
                dataType : 'JSON',
                data : {aac002:aac002,aac058:aac058},
                success: function(result) {
                if (result !=null && aac001 != result.aac001  ) {
                  //已经存在该身份证提示用户
                  if(result != null && result.aac058 == '01') {
                       mini.alert("身份证号码已经存在");
          			   mini.get("#aac006").setValue("");
         			   mini.get("#aac004").setValue("");
         			   mini.getbyName("aac002").setValue("");
                  }else if(result != null && result.aac058 != '01') {
                      mini.alert("相同类型的证件号码已经存在");
         			  mini.getbyName("aac002").setValue("");
                  }
                }else{
                	 SaveData();
                }
            }
        });
     
    }
    function loading() {
        mini.mask({
            el: document.body,
            cls: 'mini-mask-loading',
            html: '保存中...'
        });
        setTimeout(function () {
            mini.unmask(document.body);
        }, 5000);
    }
    function CloseWindow(action) {
         if (window.CloseOwnerWindow) {
             return window.CloseOwnerWindow(action);
         }else {
             window.close();
         }
    }
    function onCancel(e) {
      CloseWindow("cancel");
      self.location.reload();
    }
    function GetData() {
        var o = form.getData();
        return o;
    }
    function view() {
        Preview();      
    }
    var LODOP; //声明为全局变量 
	function Preview() {	
		CreateTwoFormPage();
		LODOP.PREVIEW();		
	}
	
	function CreateTwoFormPage(){
		LODOP=getLodop();
		var aac058=mini.getbyName("aac058").getText().trim();  //证件类型 
		var aac003=mini.getbyName("aac003").getValue().trim();  //姓名
		var aac002=mini.getbyName("aac002").getValue().trim();  //证件号码
		var aac004=mini.getbyName("aac004").getText().trim();  //性别
		var aac005=mini.getbyName("aac005").getText().trim();  //民族
		var aac006=mini.getbyName("aac006").getValue();  //出生日期
		var year = aac006.getFullYear();
		var mon = aac006.getMonth()+1;
		var day = aac006.getDate();
		LODOP.PRINT_INITA(-130,-39,1755,1065,"");
		LODOP.ADD_PRINT_TEXT(219,165,200,24,aac058);
		LODOP.SET_PRINT_STYLEA(0,"FontSize",13);
		LODOP.ADD_PRINT_TEXT(219,433,344,28,aac002);
		LODOP.SET_PRINT_STYLEA(0,"FontSize",13);
		LODOP.ADD_PRINT_TEXT(255,164,141,24,aac003);
		LODOP.SET_PRINT_STYLEA(0,"FontSize",13);
		LODOP.ADD_PRINT_TEXT(255,432,69,27,aac004);
		LODOP.SET_PRINT_STYLEA(0,"FontSize",13);
		LODOP.ADD_PRINT_TEXT(255,621,130,25,year+"-"+mon+"-"+day);
		LODOP.SET_PRINT_STYLEA(0,"FontSize",12);
		LODOP.ADD_PRINT_TEXT(293,163,134,24,aac005);
		LODOP.SET_PRINT_STYLEA(0,"FontSize",13);
		LODOP.ADD_PRINT_TEXT(293,430,70,27,"");
		LODOP.SET_PRINT_STYLEA(0,"FontSize",13);
	}
	 function isNumber(){
        	var name=mini.getbyName("aac003").getValue();
        	var p=/^([0-9]+)$/;
        	if(name!=""){
        		if(p.exec(name))
                     {
                      mini.alert("姓名不能为数字");
                     mini.getbyName("aac003").setValue(name);
                     name.focus();
                    
                     }
        	}
        
        }
</script>
</body>
</html>